package com.globalwave.filemanage;

import java.util.Map;

import com.globalwave.common.cache.CodeHelper;
import com.globalwave.common.cache.MemoryCache;

public class FMCodeHelper extends CodeHelper {
/*
    public static Map<Object, Object> getLocaleMap() throws Exception{
    	return MemoryCache.getInstance().getMap("locale", "name_") ;
    }
  */  
    public static String[] getLocales() {
    	try {
    	    return MemoryCache.getInstance().getColumnValues("FM.analysis", "name_").toArray(new String[]{}) ;
    	} catch (Exception e) {
    		logger.debug("locales not found : ", e) ;
    		return null ;
    	}
    }

    public static Map<Object, Object> getAnalyzerMap() {
    	try {
    	    return MemoryCache.getInstance().getMap("FM.analysis", "name_") ;
    	} catch (Exception e) {
    		logger.debug("analysis not found : ", e) ;
    		return null ;
    	}
    	
    }

    public static Map<Object, Object> getThumbnailMap() {
    	try {
    	    return MemoryCache.getInstance().getMap("FM.thumbnails", "name_") ;
    	} catch (Exception e) {
    		logger.debug("analysis not found : ", e) ;
    		return null ;
    	}
    	
    }
    
    public static Map<Object, Object> getSearchClassMap() {
    	try {
    	    return MemoryCache.getInstance().getMap("FM.searches", "name_") ;
    	} catch (Exception e) {
    		logger.debug("locales not found : ", e) ;
    		return null ;
    	}
    }
    public static Map<Object, Object> getSearchOptionMap() {
    	try {
    	    return MemoryCache.getInstance().getMap("FM.searches", "desc_") ;
    	} catch (Exception e) {
    		logger.debug("locales not found : ", e) ;
    		return null ;
    	}
    }
    
    public static String getIndexDir() {    	
    	try {
    	    return CodeHelper.getString("FM.Config", "name_", "index.dir") ;
    	} catch (Exception e) {
    		logger.debug("index dir not found : ", e) ;
    		return null ;
    	}
    }
    
    public static String getUploadDir() {    	
    	try {
    	    return CodeHelper.getString("FM.Config", "name_", "upload.dir") ;
    	} catch (Exception e) {
    		logger.debug("index dir not found : ", e) ;
    		return null ;
    	}
    }
    
    public static String[] getPhotoTypes() {    	
    	try {
    	    return CodeHelper.getString("FM.Config", "name_", "photo.types").split(",") ;
    	} catch (Exception e) {
    		logger.debug("index dir not found : ", e) ;
    		return null ;
    	}
    }
    
    public static Integer getInteger(String key) {
    	try {
    	    return Integer.valueOf(CodeHelper.getString("FM.Config", "name_", key)) ;
    	} catch (Exception e) {
    		logger.debug("index dir not found : ", e) ;
    		return null ;
    	}
    }
    
    public static Float getFloat(String key) {
    	try {
    	    return Float.valueOf(CodeHelper.getString("FM.Config", "name_", key)) ;
    	} catch (Exception e) {
    		logger.debug("index dir not found : ", e) ;
    		return null ;
    	}
    }
}
